package com.ybw;

import com.ybw.parseJson.YbwResult;
import com.ybw.utils.ExcelUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileOutputStream;
import java.util.List;

public class MainExcel {
    public static void main(String[] args) {
        XSSFWorkbook workbook=new XSSFWorkbook();

        XSSFSheet sheet=workbook.createSheet();

        List<YbwResult> ybwResults1=ExcelUtil.ybwResults1();


        for(int j=0 ;j<ybwResults1.size();++j){
            YbwResult entity=ybwResults1.get(j);
            int lastRowNum=sheet.getLastRowNum();
            Row dataRow=sheet.createRow(lastRowNum+1);
            dataRow.createCell(0).setCellValue(entity.getPath());
            dataRow.createCell(1).setCellValue(entity.getMethod());
            dataRow.createCell(2).setCellValue(entity.getController());
            dataRow.createCell(3).setCellValue(entity.getDescription());
        }

        FileOutputStream fos=null;
        try {
            fos = new FileOutputStream(new File("C:\\COC1.1-prod\\JSON2.0\\src\\main\\resources\\template.xlsx"));
            workbook.write(fos);
            fos.flush();
            fos.close();
        }catch(Exception e){
            e.printStackTrace();
        }

    }
}
